package com.dlc.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dlc.shop.bean.model.ImAutoReply;
import com.dlc.shop.common.constants.ImCacheNames;
import com.dlc.shop.dao.ImAutoReplyMapper;
import com.dlc.shop.service.ImAutoReplyService;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * 客服自动回复
 * @author TRACK
 */
@Service
@AllArgsConstructor
public class ImAutoReplyServiceImpl extends ServiceImpl<ImAutoReplyMapper, ImAutoReply> implements ImAutoReplyService {

    private final ImAutoReplyMapper imAutoReplyMapper;

    @Override
    @Cacheable(value = ImCacheNames.IM_AUTO_REPLY_KET, key = "#shopId")
    public ImAutoReply getByShopId(Long shopId) {
        return imAutoReplyMapper.getByShopId(shopId);
    }

    @Override
    @CacheEvict(value = ImCacheNames.IM_AUTO_REPLY_KET, key = "#imAutoReply.shopId")
    public void insert(ImAutoReply imAutoReply) {
        imAutoReplyMapper.insert(imAutoReply);
    }

    @Override
    @CacheEvict(value = ImCacheNames.IM_AUTO_REPLY_KET, key = "#imAutoReply.shopId")
    public void updateContent(ImAutoReply imAutoReply) {
        imAutoReplyMapper.updateContent(imAutoReply);
    }
}
